Save and restore the selected row in the bookmark list and the save folder
authorMatthias Clasen <mclasen@redhat.com>
Mon, 17 Jan 2005 07:05:17 +0000 (07:05 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 17 Jan 2005 07:05:17 +0000 (07:05 +0000)
2005-01-17  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkfilechooserdefault.c (shortcuts_add_bookmarks): Save
and restore the selected row in the bookmark list and the
save folder combo.  (#164290)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c

index 879fde3496c501e04fb0e6ba2302c8e096e8220a..4c426f10e742f376906dc3ba38bff330d5e53de1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_add_bookmarks): Save
+       and restore the selected row in the bookmark list and the
+       save folder combo.  (#164290)
+
 2005-01-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_new_with_backend):
index 879fde3496c501e04fb0e6ba2302c8e096e8220a..4c426f10e742f376906dc3ba38bff330d5e53de1 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_add_bookmarks): Save
+       and restore the selected row in the bookmark list and the
+       save folder combo.  (#164290)
+
 2005-01-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_new_with_backend):
index 879fde3496c501e04fb0e6ba2302c8e096e8220a..4c426f10e742f376906dc3ba38bff330d5e53de1 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_add_bookmarks): Save
+       and restore the selected row in the bookmark list and the
+       save folder combo.  (#164290)
+
 2005-01-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_new_with_backend):
index c161455426217c894861efcecc48f344b711c851..28af0a36d20efa34fd1a45a5b0e63bb031307727 100644 (file)
@@ -376,6 +376,8 @@ static gboolean shortcuts_select_func   (GtkTreeSelection      *selection,
                                         GtkTreePath           *path,
                                         gboolean               path_currently_selected,
                                         gpointer               data);
+static gboolean shortcuts_get_selected  (GtkFileChooserDefault *impl,
+                                        GtkTreeIter           *iter);
 static void shortcuts_activate_iter (GtkFileChooserDefault *impl,
                                     GtkTreeIter           *iter);
 static int shortcuts_get_index (GtkFileChooserDefault *impl,
@@ -1056,9 +1058,9 @@ shortcuts_reload_icons (GtkFileChooserDefault *impl)
   } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
 }
 
-/* If a shortcut corresponds to the current folder, selects it */
-static void
-shortcuts_find_current_folder (GtkFileChooserDefault *impl)
+static void 
+shortcuts_find_folder (GtkFileChooserDefault *impl,
+                      GtkFilePath           *folder)
 {
   GtkTreeSelection *selection;
   int pos;
@@ -1066,8 +1068,8 @@ shortcuts_find_current_folder (GtkFileChooserDefault *impl)
 
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
-  g_assert (impl->current_folder != NULL);
-  pos = shortcut_find_position (impl, impl->current_folder);
+  g_assert (folder != NULL);
+  pos = shortcut_find_position (impl, folder);
   if (pos == -1)
     {
       gtk_tree_selection_unselect_all (selection);
@@ -1079,6 +1081,13 @@ shortcuts_find_current_folder (GtkFileChooserDefault *impl)
   gtk_tree_path_free (path);
 }
 
+/* If a shortcut corresponds to the current folder, selects it */
+static void
+shortcuts_find_current_folder (GtkFileChooserDefault *impl)
+{
+  shortcuts_find_folder (impl, impl->current_folder);
+}
+
 /* Convenience function to get the display name and icon info for a path */
 static GtkFileInfo *
 get_file_info (GtkFileSystem      *file_system, 
@@ -1452,10 +1461,41 @@ shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
 {
   GSList *bookmarks;
   gboolean old_changing_folders;
-
+  GtkTreeIter iter;
+  GtkFilePath *list_selected = NULL;
+  GtkFilePath *combo_selected = NULL;
+  gboolean is_volume;
+  gpointer col_data;
+        
   old_changing_folders = impl->changing_folder;
   impl->changing_folder = TRUE;
 
+  if (shortcuts_get_selected (impl, &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), 
+                         &iter, 
+                         SHORTCUTS_COL_DATA, &col_data,
+                         SHORTCUTS_COL_IS_VOLUME, &is_volume,
+                         -1);
+
+      if (col_data && !is_volume)
+       list_selected = gtk_file_path_copy (col_data);
+    }
+
+  if (impl->save_folder_combo &&
+      gtk_combo_box_get_active_iter (GTK_COMBO_BOX (impl->save_folder_combo), 
+                                    &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), 
+                         &iter, 
+                         SHORTCUTS_COL_DATA, &col_data,
+                         SHORTCUTS_COL_IS_VOLUME, &is_volume,
+                         -1);
+      
+      if (col_data && !is_volume)
+       combo_selected = gtk_file_path_copy (col_data);
+    }
+
   if (impl->num_bookmarks > 0)
     shortcuts_remove_rows (impl,
                           shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR),
@@ -1466,12 +1506,28 @@ shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
   gtk_file_paths_free (bookmarks);
 
   if (impl->num_bookmarks > 0)
-    {
-      shortcuts_insert_separator (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
-    }
+    shortcuts_insert_separator (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
+
   if (impl->shortcuts_filter_model)
     gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
 
+  if (list_selected)
+    {
+      shortcuts_find_folder (impl, list_selected);
+      gtk_file_path_free (list_selected);
+    }
+
+  if (combo_selected)
+    {
+      gint pos;
+
+      pos = shortcut_find_position (impl, combo_selected);
+      if (pos != -1)
+       gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), 
+                                 pos);
+      gtk_file_path_free (combo_selected);
+    }
+  
   impl->changing_folder = old_changing_folders;
 }
 
@@ -1918,6 +1974,9 @@ shortcuts_get_selected (GtkFileChooserDefault *impl,
   GtkTreeSelection *selection;
   GtkTreeIter parent_iter;
 
+  if (!impl->browse_shortcuts_tree_view)
+    return FALSE;
+
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
   if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter))